
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Runtime.Serialization;
using System.Xml;
using Swaf.Container;

namespace Swaf.Security
{
	/// <summary>
	/// The Role class is the single implementation of the IRole interface.
	/// </summary>
	[Serializable]
	public class Role : IRole, ISerializable
	{
		protected string m_name="";
		/// <summary>
		/// Constructor for instantiating a role class.
		/// </summary>
		/// <param name="name"></param>
		public Role(string name)
		{
			m_name = name;
		}
		
		/// <summary>
		/// Constructor for instantiating a role class from an Xml configuration or serialized role instance.
		/// </summary>
		/// <param name="ele"></param>
		public Role(XmlElement ele)
		{
			m_name = ele.GetAttribute("name");
		}
		/// <summary>
		/// Constructor for instantiating a role from an INameAddressSupport instance (BizObj)
		/// </summary>
		/// <param name="source"></param>
		public Role(INameAddressSupport source, string nameElement)
		{
			m_name = (string) source.get(nameElement);
		}
		#region IRole Members

		
		/// <summary>
		/// Returns the name of this role.
		/// </summary>
		public string name
		{
			get
			{
				return m_name;
			}
		}

		#endregion
		public Role(System.Runtime.Serialization.SerializationInfo info, StreamingContext context)
		{
			m_name = info.GetString("name");
		}
		#region ISerializable Members

		public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, StreamingContext context)
		{
			info.AddValue("name", m_name);
		}

		#endregion
	}
}
